package Model.MarketPlace;

import java.io.Serializable;

/**
 * Represents an item in the marketplace
 *
 */
/**
 * @author Waseem
 * @version 1.0
 *
 */
public class MarketPlaceItem implements Comparable<MarketPlaceItem>, Serializable{
	/**
	 * naem of the item
	 */
	private String name;

	/**
	 * price of item
	 */
	private double price;

	/**
	 * description of item
	 */
	private String description;

	/**
	 * quantity of item
	 */
	private int quantity;
    
    /**
     * @param name
     * @param price
     * @param quantity
     * @param description
     */
    public MarketPlaceItem(String name, double price, int quantity, String description){
    	this.name = name;
    	this.price = price;
    	this.description = description;
    	this.quantity = quantity;
    }

	/* (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(MarketPlaceItem arg0) {
		if(name.equals(arg0.getName())){
			return 0;
		}
		else if(this.price < arg0.price){
			return -1;
		}
		else{
			return 1;
		}
	}
	
	/**
	 * getter for name
	 * @return name
	 */
	public String getName() {
		return name;
	}

	/**
	 * setter for name
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * getter for price
	 * @return price
	 */
	public double getPrice() {
		return price;
	}

	/**
	 * setter for price
	 * @param price
	 */
	public void setPrice(double price) {
		this.price = price;
	}

	/**
	 * getter for description
	 * @return description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * sets description
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * gets quantity
	 * @return quantity
	 */
	public int getQuantity() {
		return quantity;
	}

	/**
	 * sets quantity
	 * @param quantity
	 */
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString(){
		return name;
	}
}
